package com.zzb.codegenerator.generator.connect;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 获取连接
 */
public class ConnectPool {
    /**获取mysql连接*/
    public static Connection getConnection(String driverManager,String url,String userName, String password) throws Exception {
        System.out.println("正在获取数据库连接... ");
        try {
            Class.forName(driverManager).newInstance();
            Connection connection =
                    DriverManager.getConnection(url
                            + "&user=" + userName + "&password=" + password);
            return connection;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
